package com.kiln.juxingqs.ui.vm


import android.app.Application
import android.text.TextUtils
import androidx.lifecycle.MutableLiveData
import client.global.commlib.network.data.JsonResult
import client.global.commlib.network.data.Ret
import client.global.commlib.toast.toast
import com.kiln.juxingqs.api.bean.RechargeOrders2
import com.kiln.juxingqs.ui.viewmodel.MiddleVm

class DePayViewModel(app: Application) : MiddleVm(app) {
    val name = MutableLiveData<String>("")
    val bank = MutableLiveData<String>("")
    val num = MutableLiveData<String>()
    val txType = MutableLiveData<Int>(-1)
    val isShowing = MutableLiveData<Boolean>(false)
    val call = MutableLiveData<JsonResult<RechargeOrders2>>()

    fun commit() {
        if (TextUtils.isEmpty(name.value) ||
            TextUtils.isEmpty(bank.value)
        ) {
            toast("所有不得为空")
            return
        }
        hold({
            server.dePay(
                num.value,
                "${txType.value}",
                name.value,
                bank.value
            )
        }, {
            isShowing.value = true
        }, {
            call.value = it
        }, {

        }, {
            isShowing.value = false
        })
    }
}